package com.teach;

public class Test02 {
	public static void main(String[] args) {
		Thread t1 = new Thread(() ->{
			System.out.println("1线程开始了");	
				try {
					Thread.sleep(500);
				} catch (Exception e) {
					e.printStackTrace();
				}
				System.out.println("1线程结束了");
			
		});
		t1.start();//
		
		Thread t2 = new Thread(() ->{
			System.out.println("2线程开始了");	
				try {
					Thread.sleep(3000);
				} catch (Exception e) {
					e.printStackTrace();
				}
				System.out.println("2线程结束了");
			
		});
		t2.start();//
		
		
		Thread.yield();//主线程让步
		try {
			t1.join();
			t2.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("子线程结束了");
		t1.setDaemon(true);//true：守护线程，false：默认，用户线程
		t1.start();
	
		}
	}

